/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var maximumScore = function (nums, k) {
	const n = nums.length
	let left = k - 1,
		right = k + 1
	let ans = 0
	for (let i = nums[k]; ; --i) {
		while (left >= 0 && nums[left] >= i) {
			--left
		}
		while (right < n && nums[right] >= i) {
			++right
		}
		ans = Math.max(ans, (right - left - 1) * i)
		if (left === -1 && right === n) break
	}
	return ans
}
const nums = [1, 4, 3, 7, 4, 5],
	k = 3
const res = maximumScore(nums, k)
console.log('maximumScore :>>', res)
